home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / CalendarBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  6KB  |  195 lines

  1. package symantec.itools.awt.util;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  8.  
  9. /**
  10.  * BeanInfo for Calendar.
  11.  *
  12.  */
  13.  
  14. public class CalendarBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a CalendarBeanInfo object.
  18.      */
  19.     public CalendarBeanInfo() {
  20.     }
  21.  
  22.     /**
  23.      * Gets a BeanInfo for the superclass of this bean.
  24.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  25.      */
  26.     public BeanInfo[] getAdditionalBeanInfo() {
  27.         try {
  28.             BeanInfo[] bi = new BeanInfo[1];
  29.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  30.             return bi;
  31.         }
  32.         catch (IntrospectionException e) { throw new Error(e.toString());}
  33.     }
  34.  
  35.     /**
  36.      * Gets the SymantecBeanDescriptor for this bean.
  37.      * @return an object of type SymantecBeanDescriptor
  38.      * @see symantec.itools.beans.SymantecBeanDescriptor
  39.      */
  40.     public BeanDescriptor getBeanDescriptor() {
  41.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  42.         String s=group.getString("GroupAWTAdditions"); 
  43.  
  44.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  45.         bd.setCanAddChild(false);
  46.         bd.setWinHelp("0x1238C");
  47.         bd.setFolder(s);
  48.         bd.setToolbar(s);
  49.  
  50.         return (BeanDescriptor) bd;
  51.     }
  52.  
  53.     /**
  54.      * Gets an image that may be used to visually represent this bean
  55.      * (in the toolbar, on a form, etc).
  56.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  57.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  58.      * @return an image for this bean, always color even if requested monochrome
  59.      * @see BeanInfo#ICON_MONO_16x16
  60.      * @see BeanInfo#ICON_COLOR_16x16
  61.      * @see BeanInfo#ICON_MONO_32x32
  62.      * @see BeanInfo#ICON_COLOR_32x32
  63.      */
  64.     public java.awt.Image getIcon(int iconKind) {
  65.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  66.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  67.             java.awt.Image img = loadImage("CalendarC16.gif");
  68.             return img;
  69.         }
  70.  
  71.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  72.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  73.             java.awt.Image img = loadImage("CalendarC32.gif");
  74.             return img;
  75.         }
  76.  
  77.         return null;
  78.     }
  79.  
  80.     /**
  81.      * Gets an array of descriptions of the methods used for "connections" by
  82.      * Visual CafΘ's Interaction Wizard.
  83.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  84.      * @return method descriptions for this bean
  85.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  86.      */
  87.     public MethodDescriptor[] getMethodDescriptors() {
  88.         Class[] args;
  89.         ConnectionDescriptor connection;
  90.         java.util.Vector connections;
  91.         java.util.Vector md = new java.util.Vector();
  92.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  93.  
  94.         try{
  95.             args = new Class[1];
  96.             args[0] = java.lang.String.class ;
  97.             MethodDescriptor setDate = new MethodDescriptor(beanClass.getMethod("setDate", args));
  98.  
  99.             connections = new java.util.Vector();
  100.             connection = new ConnectionDescriptor("input", "String", "",
  101.                                     "%name%.setDate(%arg%);",
  102.                                     conn.getString("setDate"));
  103.             connections.addElement(connection);
  104.  
  105.             setDate.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  106.             md.addElement(setDate);
  107.         } catch (Exception e) { throw new Error("setDate:: " + e.toString()); }
  108.  
  109.         try{
  110.             args = null;
  111.             MethodDescriptor getSelectedColor = new MethodDescriptor(beanClass.getMethod("getSelectedColor", args));
  112.  
  113.             connections = new java.util.Vector();
  114.             connection = new ConnectionDescriptor("output", "Color", "",
  115.                                     "%name%.getSelectedColor()",
  116.                                     conn.getString("getSelectedColor"));
  117.             connections.addElement(connection);
  118.  
  119.             getSelectedColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  120.             md.addElement(getSelectedColor);
  121.         } catch (Exception e) { throw new Error("getSelectedColor:: " + e.toString()); }
  122.  
  123.         try{
  124.             args = new Class[1];
  125.             args[0] = java.awt.Color.class ;
  126.             MethodDescriptor setSelectedColor = new MethodDescriptor(beanClass.getMethod("setSelectedColor", args));
  127.  
  128.             connections = new java.util.Vector();
  129.             connection = new ConnectionDescriptor("input", "Color", "",
  130.                                     "%name%.setSelectedColor(%arg%);",
  131.                                     conn.getString("setSelectedColor"));
  132.             connections.addElement(connection);
  133.  
  134.             setSelectedColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  135.             md.addElement(setSelectedColor);
  136.         } catch (Exception e) { throw new Error("setSelectedColor:: " + e.toString()); }
  137.  
  138.         try{
  139.             args = null;
  140.             MethodDescriptor getDate = new MethodDescriptor(beanClass.getMethod("getDate", args));
  141.  
  142.             connections = new java.util.Vector();
  143.             connection = new ConnectionDescriptor("output", "String", "",
  144.                                     "%name%.getDate()",
  145.                                     conn.getString("getDate"));
  146.             connections.addElement(connection);
  147.  
  148.             getDate.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  149.             md.addElement(getDate);
  150.         } catch (Exception e) { throw new Error("getDate:: " + e.toString()); }
  151.  
  152.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  153.         md.copyInto(rv);
  154.  
  155.         return rv;
  156.     }
  157.  
  158.     /**
  159.      * Returns descriptions of this bean's properties.
  160.      */
  161.     public PropertyDescriptor[] getPropertyDescriptors() {
  162.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  163.  
  164.         try{
  165.         PropertyDescriptor defProperty = new PropertyDescriptor("date", beanClass);
  166.         defProperty.setBound(true);
  167.         defProperty.setConstrained(true);
  168.         defProperty.setDisplayName(prop.getString("date"));
  169.  
  170.         PropertyDescriptor selectedColor = new PropertyDescriptor("selectedColor", beanClass);
  171.         selectedColor.setBound(true);
  172.         selectedColor.setConstrained(true);
  173.         selectedColor.setDisplayName(prop.getString("selectedColor"));
  174.  
  175.         PropertyDescriptor layout = new PropertyDescriptor("layout", beanClass);
  176.         layout.setHidden(true);
  177.  
  178.         PropertyDescriptor[] rv = {
  179.             defProperty,
  180.             selectedColor,
  181.             layout};
  182.         return rv;
  183.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  184.     }
  185.  
  186.     /**
  187.      * Returns the index of the property expected to be changed most often by the designer.
  188.      */
  189.     public int getDefaultPropertyIndex() {
  190.         return 0;    //  the index for our default property is always 0
  191.     }
  192.  
  193.     private final static Class beanClass = Calendar.class;
  194.  
  195.     }    //  end of class CalendarBeanInfo